import amapFile from "@/utils/amap-wx";


export function getadrInfo(){
   return new Promise(function(resolve,reject){
      var myAmapFun = new amapFile.AMapWX({ key: '720d0d2fb3ab899d301e26034963ab76' });
      myAmapFun.getRegeo({
        success: function (data) {
          console.log(data)
          //成功回调 
          var desc = data[0].regeocodeData.addressComponent.city;
          var adcode = data[0].regeocodeData.addressComponent.adcode;
         
          var coordinate={};
          coordinate.latitude=data[0].latitude;
          coordinate.longitude=data[0].longitude;
          wx.setStorage({
            key: 'coordinate',
            data: coordinate,
          })
          wx.setStorage({
            key: 'address',
            data: desc,
          })
          wx.setStorage({
            key: 'qcode',
            data: adcode,
          })
          resolve(data)
        },fail:function(){
            reject("获取地址失败")
        }
      })
   })
}
export default {
    getadrInfo
}
  